package com.kun.rental.controller;

import com.kun.rental.service.IOssService;
import com.kun.rental.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/rental/oss")
public class OSSController {

    @Autowired
    private IOssService ossService;

    /**
     * 上传文件
     *
     * @param file
     * @return
     */
    @PostMapping("/upload")
    public Result upload(MultipartFile file) {
        return Result.success(ossService.upload(file));
    }

    /**
     * 删除文件
     *
     * @param url
     * @return
     */
    @DeleteMapping("/delete")
    public Result delete(String url) {
        return Result.success(ossService.delete(url));
    }
}
